home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3x / abilock.z / abilock
Encoding:
Text File  |  1998-10-20  |  6.6 KB  |  133 lines

  1.  
  2.  
  3.  
  4. AAAABBBBIIIILLLLOOOOCCCCKKKK((((3333XXXX))))                                                        AAAABBBBIIIILLLLOOOOCCCCKKKK((((3333XXXX))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      init_lock, acquire_lock, release_lock, stat_lock, spin_lock - ABI mutual
  10.      exclusion primitives
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.      ####iiiinnnncccclllluuuuddddeeee <<<<aaaabbbbiiii____mmmmuuuutttteeeexxxx....hhhh>>>>
  14.  
  15.      iiiinnnntttt iiiinnnniiiitttt____lllloooocccckkkk((((aaaabbbbiiiilllloooocccckkkk____tttt ****llllcccckkkk))));;;;
  16.  
  17.      iiiinnnntttt aaaaccccqqqquuuuiiiirrrreeee____lllloooocccckkkk((((aaaabbbbiiiilllloooocccckkkk____tttt ****llllcccckkkk))));;;;
  18.  
  19.      iiiinnnntttt rrrreeeelllleeeeaaaasssseeee____lllloooocccckkkk((((aaaabbbbiiiilllloooocccckkkk____tttt ****llllcccckkkk))));;;;
  20.  
  21.      iiiinnnntttt ssssttttaaaatttt____lllloooocccckkkk((((aaaabbbbiiiilllloooocccckkkk____tttt ****llllcccckkkk))));;;;
  22.  
  23.      vvvvooooiiiidddd ssssppppiiiinnnn____lllloooocccckkkk((((aaaabbbbiiiilllloooocccckkkk____tttt ****llllcccckkkk))));;;;
  24.  
  25. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  26.      These routines provide a simple, standard interface to base level mutual
  27.      exclusion primitives.  They are found in the library ``libmutex.so'', and
  28.      is loaded if the option ``-lmutex'' is used with _c_c(1) or _l_d(1).
  29.  
  30.      The parameter llllcccckkkk must point to memory shared by all processes wishing to
  31.      acquire or test the lock.
  32.  
  33.      The contents of the structure aaaabbbbiiiilllloooocccckkkk____tttt are as follows:
  34.           typedef struct {
  35.                unsigned int abi_lock;
  36.           } abilock_t;
  37.  
  38.      The function _iiii_nnnn_iiii_tttt______llll_oooo_cccc_kkkk must be called on a lock before any of the other
  39.      functions.  It initializes the lock to an unlocked state.  A non-zero
  40.      return status will indicate an error.
  41.  
  42.      _aaaa_cccc_qqqq_uuuu_iiii_rrrr_eeee______llll_oooo_cccc_kkkk tries once to acquire the lock referenced by llllcccckkkk.  It
  43.      returns zero if the lock was acquired, otherwise non-zero.  _aaaa_cccc_qqqq_uuuu_iiii_rrrr_eeee______llll_oooo_cccc_kkkk
  44.      can always fail, even if it is known that the lock is free and there is
  45.      only one process, this implies that _aaaa_cccc_qqqq_uuuu_iiii_rrrr_eeee______llll_oooo_cccc_kkkk should always be called
  46.      in a loop.
  47.  
  48.      _ssss_pppp_iiii_nnnn______llll_oooo_cccc_kkkk will always acquire the lock. If the lock is not immediately
  49.      available, the calling process will either spin (busy-wait) or be
  50.      suspended until the lock becomes available.  There is no implied policy
  51.      as to which (if there is more than one) waiting process will be granted
  52.      the lock.
  53.  
  54.      _ssss_tttt_aaaa_tttt______llll_oooo_cccc_kkkk returns the current state of the lock referenced by llllcccckkkk without
  55.      attempting to acquire the lock.  It returns _UUUU_NNNN_LLLL_OOOO_CCCC_KKKK_EEEE_DDDD if the lock is free,
  56.      otherwise _LLLL_OOOO_CCCC_KKKK_EEEE_DDDD.
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. AAAABBBBIIIILLLLOOOOCCCCKKKK((((3333XXXX))))                                                        AAAABBBBIIIILLLLOOOOCCCCKKKK((((3333XXXX))))
  71.  
  72.  
  73.  
  74.      _rrrr_eeee_llll_eeee_aaaa_ssss_eeee______llll_oooo_cccc_kkkk unconditionally releases the lock pointed to by llllcccckkkk.  The
  75.      ability for one process to release the lock of another process is
  76.      permitted.  A non-zero return status will indicate an error.
  77.  
  78.      These routines will work for locks shared between 32-bit and 64-bit user
  79.      programs.
  80.  
  81. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  82.      _nnnn_aaaa_nnnn_oooo_ssss_llll_eeee_eeee_pppp(2), _ssss_gggg_iiii_nnnn_aaaa_pppp(2), _uuuu_ssss_iiii_nnnn_iiii_tttt(3P).
  83.  
  84. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  85.      iiiinnnniiiitttt____lllloooocccckkkk, aaaaccccqqqquuuuiiiirrrreeee____lllloooocccckkkk, and rrrreeeelllleeeeaaaasssseeee____lllloooocccckkkk return 0 if the operation was a
  86.      success, otherwise a non-zero value.  ssssppppiiiinnnn____lllloooocccckkkk returns no value.
  87.  
  88. WWWWAAAARRRRNNNNIIIINNNNGGGGSSSS
  89.      No locks are ever freed automatically by the system.  Locks acquired by a
  90.      process that terminates remain locked.
  91.  
  92.      Since looping is necessary when attempting to acquire a lock using
  93.      _aaaa_cccc_qqqq_uuuu_iiii_rrrr_eeee______llll_oooo_cccc_kkkk, the user process could find itself in a long busy-wait
  94.      loop.  To avoid wasting CPU cycles, programs should implement some kind
  95.      of back-off strategy, perhaps calling _ssss_gggg_iiii_nnnn_aaaa_pppp(2) or _nnnn_aaaa_nnnn_oooo_ssss_llll_eeee_eeee_pppp(2) after
  96.      some number of unsuccessful calls to _aaaa_cccc_qqqq_uuuu_iiii_rrrr_eeee______llll_oooo_cccc_kkkk.
  97.  
  98.      Even though _ssss_tttt_aaaa_tttt______llll_oooo_cccc_kkkk returns status indicating that the lock is
  99.      available, a call to _aaaa_cccc_qqqq_uuuu_iiii_rrrr_eeee______llll_oooo_cccc_kkkk could still fail.
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.